//
//  UITableView+JCRefresh.m
//  HuaRun2
//
//  Created by admin on 17/8/30.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "UITableView+JCRefresh.h"
#import "MJRefreshGifHeader+CuRefreshHeader.h"
#import "MJRefreshAutoNormalFooter+CuRefreshFooter.h"
#import "MJRefresh.h"

@implementation UITableView (JCRefresh)

-(void)headerRefresh:(void (^)())handleBlock{
    
    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
        handleBlock();
    }];
    [header configurePreferences];
    
    self.mj_header = header;
}

- (void)reconfigureHeaderTips {
    MJRefreshGifHeader *header = (MJRefreshGifHeader *)self.mj_header;
    [header configurePreferences];
}

-(void)startHeaderRefresh{
    
    [self.mj_header beginRefreshing];
    
}

-(void)hiddenHeader{
    
    self.mj_header = nil;
    
    //    self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
}

-(void)endHeaderRefresh{
    
    [self.mj_header endRefreshing];
    
}

-(void)footerRefresh:(void (^)())handleBlock{
    MJRefreshAutoNormalFooter * footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        //Call this Block When enter the refresh status automatically
        handleBlock();
    }];
    [footer configurePreferences];
    self.mj_footer = footer;
}

-(void)startFooterRefresh{
    
    [self.mj_footer beginRefreshing];
    
}

-(void)endFooterRefresh{
    
    [self.mj_footer endRefreshing];
    
}

-(void)endRefreshingWithNoMoreData{
    
    [self.mj_footer endRefreshingWithNoMoreData];
    
}

-(void)hiddenFooter{
    
    self.mj_footer = nil;
    
}
@end
